package onlinejudge.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import onlinejudge.dao.NoticeDao;
import onlinejudge.entity.Notice;
import onlinejudge.service.NoticeService;

@Service
public class NoticeServiceImpl implements NoticeService {

	@Resource
	private NoticeDao noticeDao;
	private Map<String, Object> parameters=new HashMap<String, Object>();

	@Override
	public List<Notice> queryAllNotice(Map<String, Object> parameters1) {
		return noticeDao.queryNotice(parameters1);
	}

	@Override
	public void releaseNotice(Notice notice) {
		parameters.clear();
		parameters.put("noticeContent", notice.getNoticeContent());
		parameters.put("noticeDate", notice.getNoticeDate());
		noticeDao.addNotice(parameters);
	}

	@Override
	public void updateNotice(Notice notice) {
		parameters.clear();
		parameters.put("noticeId", notice.getNoticeId());
		parameters.put("noticeContent", notice.getNoticeContent());
		parameters.put("noticeDate", notice.getNoticeDate());
		noticeDao.updateNotice(parameters);
	}

	@Override
	public void deleteNotice(Integer noticeId) {
		noticeDao.deleteNotice(noticeId);
	}

	@Override
	public Integer getNoticeCount() {
		parameters.clear();
		return noticeDao.queryNotice(parameters).size();
	}
	
}
